[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
with                     Signals the Start of a WITH Statement

 with <rnames> do
   <statement>;

    Normally, if <rname> is the name of a record variable, then in order
    to  refer to a specific field in that record you must type
    "<rname>.<fname>". However, if the record name <rname> is a long name,
    or there are nested records, then referring to a field  can get
    cumbersome. The WITH statement allows you to drop the "<rname>."
    prefix. For example, instead of saying

         <rname>.<field1> := <rname>.<field2> + <rname>.<field3>;

    you can say

         with <rname> do
           <field1> := <field2> + <field3>;

        <rnames>    One or more names of record variables, separated by
                    commas. Successive names can refer to fields of
                    previously named record variables.

     <statement>    Any legal statement. If multiple statements are
                    desired, use a compound statement.

  -------------------------------- Example ---------------------------------

           type
             Student = record
               Last,First : string[20];
               SSN        : string[9];
               GPA        : Real;
               Passing    : Boolean
             end;

           var
             Who    : Student;

           begin
             with Who do begin
               First := 'Rufus';
               Last := 'Jones';
               GPA  := 2.85;
               Passing := True
             end
           end.

See Also: begin
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson